1. Field of the Invention
The present invention relates generally to an improved data processing system and in particular to a method and apparatus for processing data. Still more particularly, the present invention relates to a computer implemented method, apparatus, and computer usable program code for call stack sampling in a data processing system.
2. Description of the Related Art
In writing code, runtime analysis of the code is often performed as part of an optimization process. Runtime analysis is used to understand the behavior of components or modules within the code using data collected during the execution of the code. The analysis of the data collected may provide insight to various potential misbehaviors in the code. For example, an understanding of execution paths, code coverage, memory utilization, memory errors and memory leaks in native applications, performance bottlenecks, and threading problems are examples of aspects that may be identified through analyzing the code during execution.
The performance characteristics of code may be identified using a software performance analysis tool. The identification of the different characteristics may be based on a trace facility of a trace system. A trace tool may be used using various techniques to provide information, such as execution flows as well as other aspects of an executing program. A trace may contain data about the execution of code. For example, a trace may contain trace records about events generated during the execution of the code. A trace also may include information, such as a process identifier, a thread identifier, and a program counter. Information in the trace may vary depending on the particular profile or analysis that is to be performed. A record is a unit of information relating to an event that is detected during the execution of the code.
Attempting to obtain an unbiased time based sample call stack from a virtual machine, such as a Java™ virtual machine, on an operating system may be a difficult task. Java™ is a trademark of Sun Microsystems, Inc. Many approaches are presently used for obtaining call stack information. These approaches include using entry/exit events, an application timer tick, or instrumenting code to sample the instrumented values.
These types of techniques, however, in a symmetric multi-processor (SMP) system, have a drawback of requiring additional instrumentation in the code or possibly allowing the thread whose call stack is to be sampled to migrate to a different processor during the sampling process. Obtaining call stacks for large applications may cause a significant performance degradation to the application being profiled. Using entry and exit events for each method and processing may range from two to twenty times the normal processing overhead for larger applications.
The approach of using a timer tick to sample or obtain call stack information by signaling a sampling thread that obtains the call stack may produce desirable results with less system perturbation. To obtain and return a call stack, a Java™ virtual machine shifts into a safe state. In order to shift into this safe state, the Java™ virtual machine may obtain a lock and affect normal processing. Other issues can occur with this type of sampling. For example, when the call stack is requested, the thread that has been interrupted may migrate to a different processor. Migration of the thread from one processor to another processor may result in reports that are biased. Further, additional idle time may occur with the Java™ virtual machine moving into a safe state.
Therefore, it would be advantageous to have a computer implemented method, apparatus, and computer usable program code that overcome some or all of the problems described above as well as possibly other problems.